package com.xinzhi.controller;

import com.xinzhi.pojo.Poinos;
import com.xinzhi.pojo.Reason;
import com.xinzhi.pojo.dto.Dtoteshujia;
import com.xinzhi.service.AppraisalService;
import com.xinzhi.service.DeleteappraisalService;
import com.xinzhi.service.PoinosService;
import com.xinzhi.service.ReasonService;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController

public class AppraisalController {
    @Autowired
    private ReasonService rensonService;
    @Autowired
    private AppraisalService appraisalService;
    @Autowired
    private PoinosService poinosService;
    @Autowired
    private DeleteappraisalService deleteappraisalService;


    /**
     * 特殊加分申请全部查询接口
     */

    @GetMapping("/getAppraisalAll")
    public  Result getAppraisalAlls() {
        return appraisalService.getAppraisalAll();
    }


    /**
     * 特殊加分申请根据对象查询接口
     * @param object
     * @return
     */
    @GetMapping("/getAppraisalByObject")
    public Result getAppraisalByObject(String object){
        return appraisalService.getAppraisalByObject(object);
    }


    /**
     * 特殊加分申请修改接口
     */
    @PostMapping("/updateReason")
    public Result updateReason(@RequestBody Reason add) {
        return poinosService. updateReason(add);
    }


    /**
     * 特殊加分申请的新增接口
     */
    @PostMapping("/index")
    public Result index(@RequestParam String object,@RequestParam String poinexe, @RequestParam Integer  extra) {
        // 调用service层的方法
        Result result = rensonService.addScore(object, poinexe,extra);
        return Result.ok(result);
    }

    /**
     * 特殊扣分申请修改接口
     */

    @PostMapping ("/updatePoinos")
    public Result updatePoinos(@RequestBody Poinos poinos) {
        return poinosService. updatePoinos(poinos);
    }


    /**
     * 特殊加分申请根据状态查询接口
     * @param statet
     * @return
     */
    @GetMapping("/queryStudents3")
    public Result<Dtoteshujia> queryStudents3(String statet) {
        return rensonService.selectreason(statet);
    }

    /**
     * 特殊加分申请根据年份查询的接口
     */

    @GetMapping("/queryStudents4")
    public Result<Dtoteshujia> queryStudents4(Integer year) {
        return rensonService.selectreason1(year);
    }

    /**
     * 特殊加分里的逻辑删除
     * @param object
     * @param deleted
     * @return
     */
    @GetMapping("/deleteappraisal")
    Result updateByPrimaryKey(String object,Integer deleted){
        Result result = deleteappraisalService.updateByPrimaryKey(object, deleted);
        return result;
    }

    /**
     * 特殊扣分申请根据年份查询接口
     */

    @GetMapping("/selectAllsByYear")
    public  Result queryStudents2(String object,String year) {
        return appraisalService.selectAllsByYear(object,year);
    }
}
